<?php

declare(strict_types=1);

namespace app\admin\controller;

use addons\Builder\facade\Builder;
//该文件为自动生成，请按需修改
class UserBonus extends Base
{
    //主键，默认为id
    protected string $pk = 'id';

    //主模型
    protected string $model = '\app\common\model\UserBonus';
    
    //关联模型
    protected $hasOne = ['user','bonus'];

    public function index(): string
    {
        $param = $this->request->get();
        if (isset($param['id'])) {
            $map = ['bonus_id', '=', $param['id']];
        } else {
            $map = ['bonus_id', '>', 0];
        }
        return Builder::Table()
            ->autoStructure($this->model, $this->pk, '')
            ->addExtraMap([$map])
            ->fetch();
    }
}
